package com.hu.utils;


import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class RestfulUtil {

    public static String toRestful(Object data,String msg,Integer state){
        Map<String,Object> map = new HashMap<>();
        map.put("state",state);
        map.put("msg",msg);
        map.put("data",data);
        return JSONObject.toJSONString(map);
    }

    public static String toRestful(Object data){
        Map<String,Object> map = new HashMap<>();
        map.put("state","200");
        map.put("msg","操作成功");
        map.put("data",data);
        return JSONObject.toJSONString(map);
    }
}
